/*!
 * Copyright (C) 2020 - All Rights Reserved by
 * @author : ZhaoYanbo
 * @email  : zyb920@hotmail.com
 * @created: 2020-10-31
 * @version: 1.0.0.0
 *
 */

#ifndef LE_RULER_H
#define LE_RULER_H

#include <QPixmap>

/// 歌词编辑器的标尺(LE = Lyric&&Edit)
class LE_Ruler final
{
public:
    LE_Ruler();
    ~LE_Ruler();

    ///间距放大
    bool zoomIn();
    bool canZoomIn() const;

    ///间距缩小
    bool zoomOut();
    bool canZoomOut() const;

    void setColor(const QString &lineColor,
                  const QString &textColor);

    int curZoom() const { return m_zoomIndex+1; }
    void reset();

    ///通过x坐标获取标尺上对应的值
    float pos2value(int x);

    ///通过value获取对应的x坐标
    int value2pos(float value);

    float curSpaceValue() const {
        return m_zoom[m_zoomIndex];
    }

    float curStartValue()const {
        return m_startValue;
    }
    void setCurStartValue(float v);

    //处理
    void doMoveStart();
    void doMove(int x);
    bool doMove();
    void doMoveEnd();

    ///
    /// \brief update 更新标尺
    /// \param width      标尺宽度
    /// \param height     标尺高度
    /// \return
    ///
    QPixmap update(int width, int height);

private:
    int m_zoomIndex;
    int m_zoomCount;
    float m_zoom[5];

    float m_startValue;

    bool  m_bMove;
    float m_moveValue;

    QString m_lineColor;
    QString m_textColor;
};

#endif // LE_RULER_H
